const TokenKey = 'AccessToken'

const UserInfo = 'UserInfo'

export function getToken() {
  return localStorage.getItem(TokenKey);
}

export function setToken(token) {
  
  localStorage.setItem(TokenKey,'Bearer ' + token.AccessToken);
  localStorage.setItem(UserInfo,JSON.stringify(token));

  setTimeout(()=>{
    localStorage.removeItem(TokenKey);
    localStorage.removeItem(UserInfo);
  },token.StateTime)
}

export function removeToken() {
  return localStorage.removeItem(TokenKey)
}

export function getUserInfo(){
  return localStorage.getItem(UserInfo);
}